package com.zhs.study.test;

/**
 * @Author: zhenghuisheng
 * @Date: 2023/8/1 23:19
 */
public class Product {
    //唤醒的数量
    public static final int finalCount = 500;
    //成员变量
    public int count;
    public Product(int count){
        this.count = count;
    }
    //给生产者改变数量
    public void addCount(){
        count = count + 100;
    }
    //消费者线程
    public synchronized void waitCount() throws InterruptedException {
        //不满足条件
        while (this.count <= finalCount){
            System.out.println("线程即将等待");
            //等待
            wait();
            //业务逻辑
            System.out.println("消费者消费了" + this.count + "公里数");
        }
    }
}
